package com.aplikata.evok.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.aplikata.evok.bo.ContactPerson;
import com.aplikata.service.PublicService;
import com.aplikata.util.StringUtil;


/** 
* @ClassName: ContactPersonDataModel 
* @Description: TODO
* @author Huyun
* @date May 23, 2012 1:50:42 PM 
*  
*/
public class ContactPersonDataModel extends ListDataModel<ContactPerson> implements SelectableDataModel<ContactPerson> {
	private PublicService publicService;

	public ContactPersonDataModel() {
	}

	public ContactPersonDataModel(PublicService publicService, List<ContactPerson> data) {
		super(data);
		this.publicService = publicService;
	}

	@Override
	public ContactPerson getRowData(String arg0) {
		if (StringUtil.isStrEmpty(arg0) || "null".equals(arg0))
			return null;

		return (ContactPerson) publicService.get(ContactPerson.class, Long.parseLong(arg0));
	}

	@Override
	public Object getRowKey(ContactPerson contactPerson) {
		return contactPerson.getId();
	}

	public PublicService getPublicService() {
		return publicService;
	}

	public void setPublicService(PublicService publicService) {
		this.publicService = publicService;
	}

}